package com.group2.operations.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.group2.operations.mapper.ClientMapper;
import com.group2.operations.mapper.StoreMapper;
import com.group2.operations.model.Store;
import com.group2.operations.model.dto.CountPeopleDTO;
import com.group2.operations.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class StoreServiceImpl implements StoreService{
    @Autowired
    private StoreMapper storeMapper;
    @Autowired
    private ClientMapper clientMapper;

    /**
     * 根据代理商ID列出其下的所有厅店
     * @param uid 代理商ID
     * @param pageNum 页数
     * @param pageSize 页容量
     * @return
     */
    @Override
    public PageInfo<Store> listAllStores(int uid, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Store> list = storeMapper.queryStoreByUid(uid);
        return new PageInfo<>(list);
    }

    /**
     * 根据厅店ID获取厅店当前状态
     * @param sid 厅店ID
     * @return
     */
    @Override
    public boolean getState(int sid) {
        return storeMapper.queryStateById(sid);
    }

    /**
     * 获取厅店每天的到店人数
     * @param sid 厅店ID
     * @return
     */
    @Override
    public List<CountPeopleDTO> countByDay(int sid) {
        return clientMapper.countByDay(sid);
    }
}
